import UIKit

public class PaddingLabel: UILabel {
    public var padding: UIEdgeInsets = .zero {
        didSet {
            invalidateIntrinsicContentSize()
        }
    }
    
    public override func drawText(in rect: CGRect) {
        super.drawText(in: rect.inset(by: padding))
    }
    
    public override var intrinsicContentSize: CGSize {
        var size = super.intrinsicContentSize
        size.width += padding.left + padding.right
        size.height += padding.top + padding.bottom
        return size
    }
    
    public override func sizeThatFits(_ size: CGSize) -> CGSize {
        var fitSize = super.sizeThatFits(
            CGSize(
                width: size.width - padding.left - padding.right,
                height: size.height - padding.top - padding.bottom
            )
        )
        fitSize.width += padding.left + padding.right
        fitSize.height += padding.top + padding.bottom
        return fitSize
    }
} 